home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
dalla rivista
/
host contacted
/
imengv3.41p2.lha
/
ImEngV3.41p2
/
Extra
/
ARexx
/
IndexReverse.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-01-09
|
2KB
|
61 lines
/*
** $VER: IndexReverse.rexx 1.01 (9/1 Stockholm/Sweden)
** Copyright © 1997 by Patrik M Nydensten
**
** Reverses the order of indexed files within a selected index range.
** The new name will be the old basename but with another index number.
** The index number will be: <high_index> - <current_index> + 1
**
** Usage: <first_index_file> <last_index_file>
*/
options results
parse arg files
if pos('"',files) = 0 then parse var files file1 file2
else parse var files '"'file1'"' '"'file2'"'
fix = strip(get_ext(file1)) ; lix = strip(get_ext(file2))
if ((~datatype(fix,'N'))|(~datatype(lix,'N'))) then errorx('Error: Bad index number in file name.')
fi = min(fix,lix) ; li = max(fix,lix)
do i = fi to li
new_file = get_base(file1)'.'right(fi+li-i,4,'0')
old_file = get_base(file1)'.'right(i,4,'0')
if exists(old_file) then do
address 'COMMAND' 'rename' '"'old_file'"' '"'new_file'!"'
end
else say 'Error: Could not locate file "'old_file'".'
end
do i = fi to li
new_file = get_base(file1)'.'right(fi+li-i,4,'0')
if exists(new_file'!') then do
if ~exists(new_file) then address 'COMMAND' 'rename' '"'new_file'!"' '"'new_file'"'
else say 'Error: An image with that name already exist!'d2c(10)||,
' File: "'new_file'"'
end
end
exit
/* --[ proc ]--------------------------- */
errorx:
parse arg text
say text
exit 5
return 0
get_ext:
parse arg get_ext_in
if lastpos('.',get_ext_in) ~= 0 then get_ext_back = substr(get_ext_in,1+lastpos('.',get_ext_in))
else get_ext_back = ''
return get_ext_back
get_base:
parse arg get_base_in
if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1)
else get_base_back = get_base_in
return get_base_back